package com.ruoyi.ihome.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ihome.domain.IhCheck;
import com.ruoyi.ihome.service.IIhCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间入住期限Controller
 * 
 * @author ruoyi
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/ihome/Check")
public class IhCheckController extends BaseController
{
    @Autowired
    private IIhCheckService ihCheckService;

    /**
     * 查询房间入住期限列表
     */
    @PreAuthorize("@ss.hasPermi('ihome:Check:list')")
    @GetMapping("/list")
    public TableDataInfo list(IhCheck ihCheck)
    {
        startPage();
        List<IhCheck> list = ihCheckService.selectIhCheckList(ihCheck);
        return getDataTable(list);
    }

    /**
     * 导出房间入住期限列表
     */
    @PreAuthorize("@ss.hasPermi('ihome:Check:export')")
    @Log(title = "房间入住期限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IhCheck ihCheck)
    {
        List<IhCheck> list = ihCheckService.selectIhCheckList(ihCheck);
        ExcelUtil<IhCheck> util = new ExcelUtil<IhCheck>(IhCheck.class);
        util.exportExcel(response, list, "房间入住期限数据");
    }

    /**
     * 获取房间入住期限详细信息
     */
    @PreAuthorize("@ss.hasPermi('ihome:Check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ihCheckService.selectIhCheckById(id));
    }

    /**
     * 新增房间入住期限
     */
    @PreAuthorize("@ss.hasPermi('ihome:Check:add')")
    @Log(title = "房间入住期限", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IhCheck ihCheck)
    {
        return toAjax(ihCheckService.insertIhCheck(ihCheck));
    }

    /**
     * 修改房间入住期限
     */
    @PreAuthorize("@ss.hasPermi('ihome:Check:edit')")
    @Log(title = "房间入住期限", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IhCheck ihCheck)
    {
        return toAjax(ihCheckService.updateIhCheck(ihCheck));
    }

    /**
     * 删除房间入住期限
     */
    @PreAuthorize("@ss.hasPermi('ihome:Check:remove')")
    @Log(title = "房间入住期限", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ihCheckService.deleteIhCheckByIds(ids));
    }
}
